<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>编辑文章</title>
	<link type="text/css" rel="stylesheet" href="<?php echo base_url() ?>public/css/style.css" />
	<link href="<?php echo base_url() ?>public/umeditor1_2_2-utf8-php/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
</head>
<body>

<div class="wrapper">
<?php echo validation_errors(); ?>
<?php echo form_open('/article/edit'); ?> 
<form class="form-item" method="post" action="">
	<input type="hidden" name="aid" value="<?php echo $article->aid ?>">
      <p class="p-item"><label class="lab-item">标题：</label><input type="text" class="txt" id="title" name="title" value="<?php echo $article->title ?>" /></p>
	  <p class="p-item"><label class="lab-item">正文：</label>
        <textarea id="content" name="content" style="display:none;"></textarea>
        <!-- style给定宽度可以影响编辑器的最终宽度 -->
        <script type="text/plain" id="myEditor" style="width:600px;height:240px;">
            <?php echo $article->content ?>
        </script>
    </p>
	<p class="p-btn"><input name="botton_submit" class="btn-sub" type="button" value="提交" /></p>
</form>
</div>
<script type="text/javascript" src="<?php echo base_url() ?>public/js/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="<?php echo base_url() ?>public/umeditor1_2_2-utf8-php/umeditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="<?php echo base_url() ?>public/umeditor1_2_2-utf8-php/umeditor.min.js"></script>
<script type="text/javascript" src="<?php echo base_url() ?>public/umeditor1_2_2-utf8-php/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
var um = UM.getEditor('myEditor');
$('.btn-sub').click(function() {
  var cont = UM.getEditor('myEditor').getContent();
  $('#content').html(cont)
  $('.form-item').submit();
});
// $.ajax({
// 	url:'/article/json',
// 	type : 'get',
// 	success : function (data) {
// 		var data = eval('('+data+')');
// 		window.console && console.log(data);
// 	}
// });

// $('.btn-sub').click(function() {
// 	var data = {
// 		title:$('#title').val(),
// 		content : $('#content').val()
// 	}
// 	$.post('/article/insert',data,function (data) {
// 		window.console && console.log(data);
// 	});
// 	return false;
// });

</script>
</body>
</html>